﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RFID_Interface.DTO
{
    public class SendDeliveryRequest
    {
        public string BillNo { get; set; }
        public string StockBillNo { get; set; }
        public string StockNumber { get; set; }
        public string OrderBillNo { get; set; }
        public DateTime BillDate { get; set; }
        public int UserID { get; set; }

        public List<SendDeliveryEntry> Entry { get; set; }

        public SendDeliveryResponse Save()
        {
            using (var db = DB.Open())
            {
                if (UserID <= 0) throw new Exception("用户ID不能为空");

                //获取原始单据
                var orgBill = DeliveryBillResponse.Get(BillNo);

                //判定当前单据物料与数量是否与原单相符


                //标记已经发货
                db.ExecNoQuery("update icstockbill_1001 set fbillerid=@userid where fbillno=@billno", UserID, BillNo);
            }

            return new SendDeliveryResponse { ErrMsg = string.Empty, Result = 'S' };
        }
    }
    public class SendDeliveryEntry
    {
        public int LineID { get; set; }
        public string ICItemNumber { get; set; }
        public decimal Qty { get; set; }
        public string Unit { get; set; }
        public string Barcode { get; set; }
        public string Barcode2 { get; set; }

    }

    public class SendDeliveryResponse
    {
        public char Result { get; set; }
        public string ErrMsg { get; set; }
    }
}